package com.lottery.htbc.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lottery.htbc.mapper.UserAccountMapper;
import com.lottery.htbc.pojo.SynRecord;
import com.lottery.htbc.pojo.UserAccount;

@Service
public class UserAccountDao {

	/**
	 * 未同步
	 */
	private static final int IS_SYN_NOT=-1;
	/**
	 * 已经同步
	 */
	private static final int IS_SYN_FINISH=1;

	@Autowired
	private UserAccountMapper userAccountMapper;

	/**
	 * 查询所有等待同步的账户
	 * @return
	 */
	public List<UserAccount> queryAllWait(){
		UserAccount param=new UserAccount();
		param.setIsValid(1);
		param.setIsSyn(IS_SYN_NOT);
		return	userAccountMapper.select(param);
	}



	/**
	 * 查询所有有效的账户
	 * @return
	 */
	public List<UserAccount> queryAllValid(){
		UserAccount param=new UserAccount();
		param.setIsValid(1);
		return	userAccountMapper.select(param);
	}
	/**
	 * 批量同步 余额
	 * @param syns
	 */
	public void synBatch(List<UserAccount> syns){
		if(syns!=null&&syns.size()>0){
			for(UserAccount syn:syns){
				syn.setIsSyn(IS_SYN_FINISH);
			}
			userAccountMapper.updateBatch(syns);
		}
	}


}
